<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Layout {
	
    protected $site_title = 'IMDB.my';
    protected $ci;
    public $jquery;
    public $jqueryui;

    public function __construct() {
        $this->ci = CI_Controller::get_instance();
        $this->setSiteTitle($this->ci->config->item('site_title'));
    }

    public function render($view, $data = array(), $title = 'Home', $options = array('jquery' => true, 'jqueryui' => false, 'css' => 'style.css')) {
        $page = array(
        'headSection'   =>  $this->loadHeadSection($title, $options),
        'header'        =>  $this->loadHeader()
        //'content'   =>  $this->loadContent($view, $data),
        //'footer'    =>  $this->loadFooter($this->site_title)
    );
    $this->ci->load->view('layout/main.php', $page);
    }

    public function loadHeader($data = array()) {
        return $this->ci->load->view('layout/header', $data, true);
    }

    public function loadContent($view, $data = array()) {
        return $this->ci->load->view($view, $data, true);
    }

    public function loadFooter($site_title = '') {
    if (!$site_title) {
        $site_title = $this->site_title;
    }
        return $this->ci->load->view('layout/footer', compact('site_title'), true);
    }

    public function loadHeadSection($title = 'Home', $data = array('jquery' => true, 'jqueryui' => false)) {
        $data['title'] = $this->setPageTitle($title);
        return $this->ci->load->view('layout/head_section', $data, true);
    }

    public function setPageTitle($title = 'Home') {
        return $this->site_title . ' - ' . $title;
    }
	
    public function setSiteTitle($title) {
        $this->site_title = $title;
    }

    public function getSiteTitle() {
        return $this->site_title;
    }
	
}